{include file="public/header" /}
<div class="header">
	<span>部门列表</span>
	<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" onclick="add()">
		<i class="layui-icon layui-icon-add-1"></i>添加
	</button>
	<div></div>
</div>
<table class="layui-table">
	<thead>
		<tr>
			<th>部门名</th>
			<th>状态</th>
			<th>添加时间</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
		{volist name="group" id='vo'}
			<tr>
				<td>{$vo.group_name}</td>
				<td>{$vo.status==1?'开启':'<span style="color:red;">禁用</span>'}</td>
				<td>{:date('Y-m-d H:i:s',$vo.time_add)}</td>
				<td>
					<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" onclick="edit({$vo.group_id})">
						<i class="layui-icon layui-icon-edit"></i>编辑
					</button>
					<button type="button" class="layui-btn layui-btn-primary layui-btn-xs" onclick="del({$vo.group_id})">
						<i class="layui-icon layui-icon-delete"></i>删除
					</button>
				</td>
			</tr>
		{/volist}
	</tbody>
</table>
<script type="text/javascript">
	layui.use(['layer'],function(){
		layer = layui.layer;
		$ = layui.jquery;
	});
	// 添加
	function add(){
		layer.open({
			type: 2,
			title: '添加部门',
			shade: 0.3,
			area: ['450px','550px'],
			content: "{$config['admin_route']}bewadmin/groupadd"
		});
	}
	// 编辑
	function edit(group_id){
		layer.open({
			type: 2,
			title: '编辑部门',
			shade: 0.3,
			area: ['450px','550px'],
			content: "{$config['admin_route']}bewadmin/groupedit?group_id="+group_id
		});
	}
	// 删除
	function del(group_id){
		layer.confirm('确定要删除吗？', {
			icon:3,
			btn: ['确定','取消']
		}, function(){
		  $.post("{$config['admin_route']}bewadmin/groupdel",{'group_id':group_id},function(res){
				if(res.code>0){
					layer.alert(res.msg,{icon:2});
				}else{
					layer.msg(res.msg,{icon:1});
					setTimeout(function(){window.location.reload();},1000);
				}
		  },'json');
		});
	}
</script>
{include file="public/tail" /}